package day16.晚间练习.tcp的程序练习;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;
//客户端
public class ClientDemo {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("127.0.0.1", 10001);
        OutputStream os = s.getOutputStream();
        os.write("nihaoa".getBytes());
        s.shutdownOutput();
        BufferedReader br = new BufferedReader(new InputStreamReader((s.getInputStream())));
        String line;
        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }
        br.close();
        os.close();
        s.close();
    }
}
